<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:office="clr-namespace:OpenLS.UI"
    x:Class="OpenLS.UI.GroupBoxResources"
    >
  <ResourceDictionary.MergedDictionaries>
    <!--<ResourceDictionary Source="RibbonBrushes.xaml"></ResourceDictionary> -->
  </ResourceDictionary.MergedDictionaries>
  <ControlTemplate TargetType ="{x:Type GroupBox}" x:Key="expandedGroupBox">
    <Border BorderBrush ="{StaticResource groupBorderBrush}" BorderThickness ="1" CornerRadius="4"  Margin="{TemplateBinding Margin}" Background="{TemplateBinding Background}">
      <Grid >
        <Grid.RowDefinitions>
          <RowDefinition Height ="*"></RowDefinition>
          <RowDefinition Height ="16"></RowDefinition>
        </Grid.RowDefinitions>
        <Rectangle Fill="{TemplateBinding Background}" RadiusX="3" RadiusY="3">
        </Rectangle> 
        <ContentPresenter HorizontalAlignment ="Left" VerticalAlignment ="Top"/>
        <Rectangle Grid.Row ="1" Fill="#FFC2D9F0" x:Name="headerRect"/>
        <ContentControl HorizontalAlignment ="Stretch" Foreground="#3e6aaa" Background ="#FFC2D9F0"
        Content ="{TemplateBinding Header}" Grid.Row="1" HorizontalContentAlignment="Center" TextBlock.TextAlignment="Center"/>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property ="IsMouseOver" Value="True">
        <Setter Property="Fill" TargetName="headerRect">
          <Setter.Value>
            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
              <LinearGradientBrush.GradientStops>
                <GradientStop Offset="0" Color="#FFC8E0FF" />
                <GradientStop Offset="0.268041237113401" Color="#FFC8E0FF" />
                <GradientStop Offset="0.94845360824742331" Color="#FFD6EDFF" />
                <GradientStop Offset="1" Color="#FFFFFFFF" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Setter.Value>
        </Setter>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="toggleGroupBoxStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border x:Name="ClassicBorder"
                  Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
            <DockPanel x:Name="ContentPanel" Background="Transparent">
              <Path Data="M0,0 L6,0 L3,2 Z" Fill ="DarkBlue" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Margin="2"/>
              <ContentPresenter x:Name="ContentHost" Margin="{TemplateBinding Padding}" DockPanel.Dock="Bottom"/>
            </DockPanel>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Background" Value="{StaticResource groupBoxContentBrush}"/>
    <Setter Property="Padding" Value="4 6 4 6"/>
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="true">
        <Setter Property="Background" Value="{StaticResource groupBoxContentPressedBrush}"  />
      </Trigger>
      <Trigger Property="IsMouseOver" Value="true">
        <Setter Property="Background" Value="{StaticResource groupBoxContentHoverBrush}"  />
      </Trigger>
    </Style.Triggers>
  </Style>
  

  <ControlTemplate TargetType="{x:Type GroupBox}" x:Key="collapsedGroupBox">
    <Border BorderBrush ="#7eadd3" BorderThickness ="1" CornerRadius="3" Margin="{TemplateBinding Margin}">
      <Grid>
        <ToggleButton Content="{TemplateBinding Header}" x:Name="toggle" Click="OnToggleClick" VerticalAlignment ="Stretch" 
                     Style="{StaticResource toggleGroupBoxStyle}" ></ToggleButton>
        <Popup PlacementTarget="{Binding ElementName=toggle}" x:Name="popup" StaysOpen="False" Closed="OnPopupClosed" >
          <Border BorderBrush ="#7eadd3" BorderThickness ="1" CornerRadius="3">
            <Grid Background="#c8e0ff">
              <Grid.RowDefinitions>
                <RowDefinition Height ="*"></RowDefinition>
                <RowDefinition Height ="16"></RowDefinition>
              </Grid.RowDefinitions>
              <Rectangle Fill="{TemplateBinding Background}">
              </Rectangle>
              <ContentPresenter HorizontalAlignment ="Left" VerticalAlignment ="Center"/>
              <ContentControl
              HorizontalAlignment ="Stretch"
              Foreground="#3e6aaa" Background ="#c8e0ff"
              Content ="{TemplateBinding Header}" Grid.Row="1" TextBlock.TextAlignment="Center"/>
            </Grid>
          </Border>
        </Popup>
      </Grid>

    </Border>
  </ControlTemplate>
  <ControlTemplate TargetType="{x:Type GroupBox}" x:Key="autoCollapsingGroupBox">
    <office:AutoCollapsingPanel NarrowTemplate="{StaticResource collapsedGroupBox}" 
                                WideTemplate="{StaticResource expandedGroupBox}">
      <GroupBox Header ="{TemplateBinding Header}" Content="{TemplateBinding Content}" Template="{StaticResource expandedGroupBox}"/>
    </office:AutoCollapsingPanel>
  </ControlTemplate>
  <Style TargetType="{x:Type GroupBox}" x:Key="ribbonGroupBox">
    <Setter Property="Template" Value="{StaticResource autoCollapsingGroupBox}"></Setter>
    <Setter Property="Background" Value="{StaticResource groupBoxContentBrush}"></Setter>
    <Setter Property="Margin" Value="1 0.5 1 0.5"></Setter>
    <Style.Triggers>
      <Trigger Property ="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource groupBoxContentHoverBrush}"/> 
      </Trigger>
    </Style.Triggers>
  </Style>


</ResourceDictionary>